package com.zw.admin.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.zw.admin.server.model.PPurchOrders;

@Mapper
public interface PPurchOrdersDao {

    @Select("select * from p_purch_orders t where t.id = #{id}")
    PPurchOrders getById(Long id);

    @Delete("delete from p_purch_orders where id = #{id}")
    int delete(Long id);

    int update(PPurchOrders pPurchOrders);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into p_purch_orders(buydate, supplier_no, type, status, pre_goods_amount, pre_expenses, pre_amount, cancel_amount, amount, transit_type, plan_receive_day, createTime, updateTime) values(#{buydate}, #{supplierNo}, #{type}, #{status}, #{preGoodsAmount}, #{preExpenses}, #{preAmount}, #{cancelAmount}, #{amount}, #{transitType}, #{planReceiveDay}, #{createTime}, #{updateTime})")
    int save(PPurchOrders pPurchOrders);
    
    int insert(PPurchOrders pPurchOrders);
    
    int count(@Param("params") Map<String, Object> params);

    List<PPurchOrders> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
